package com.goktech.sportsmall.controller;

import com.goktech.sportsmall.bean.ShoppingCartBean;
import com.goktech.sportsmall.service.ShoppingCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/cart")
public class VueShoppingCartController {

    @Autowired(required = false)
    ShoppingCartService shoppingCartService;
    // 添加商品到购物车
    @RequestMapping(value = "/insert",method = RequestMethod.POST)
    public Map<String,Object> insertShoppingCart(ShoppingCartBean shoppingCartBean){
        return shoppingCartService.insertShoppingCart(shoppingCartBean);
    }
    // 根据用户查询商品
    @RequestMapping(value = "/selectByIg",method = RequestMethod.GET)
    public Map<String,Object> selectByUId(String uId){
        return shoppingCartService.selectByUId(uId);
    }
    // 根据商品编号
    @RequestMapping(value = "/delete",method = RequestMethod.DELETE)
    public Map<String,Object> deleteByNo(int scId){
        return shoppingCartService.deleteByNo(scId);
    }
    // 更新商品的信息
    @RequestMapping(value = "/update",method = RequestMethod.GET)
    public Map<String,Object> updateComm(ShoppingCartBean shoppingCartBean){
        return shoppingCartService.updateComm(shoppingCartBean);
    }
}
